package resources.bean;

import hr.dao.BranchDAO;
import hr.dao.DepartmentDAO;
import hr.dao.DesignationDAO;
import hr.dao.EmployeeDAO;

import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.SelectItem;

import resources.dao.UtilDAO;
import resources.pojo.hr_employee;
import resources.util.Tool;

@ManagedBean(name="utilBean")
@SessionScoped
public class UtilBean {
	
	private ArrayList<SelectItem> listDepartment;
	private ArrayList<SelectItem> listDesignation;
	private ArrayList<SelectItem> listBranch;
	private ArrayList<SelectItem> listAttendanceType;
	private ArrayList<hr_employee> listEmployee;
	
	public void initListEmployee(){
		if(!Tool.isPostBack()){
			listEmployee= new ArrayList<hr_employee>();
		}
	}
	
	public void initAttendanceType(){
		if(!Tool.isPostBack()){
			listAttendanceType = new ArrayList<SelectItem>();
			listAttendanceType.addAll(UtilDAO.getSelectItem("attendance-type"));
		}
	}
	
	public void refreshAttendanceType(){
		listAttendanceType = new ArrayList<SelectItem>();
		listAttendanceType.addAll(UtilDAO.getSelectItem("attendance-type"));
	}
	
	public void initDepartment(){
		if(!Tool.isPostBack()){
			listDepartment = new ArrayList<SelectItem>();
			listDepartment.addAll(UtilDAO.getSelectItem("department"));
		}
	}
	
	public void refreshDepartment(){
		listDepartment = new ArrayList<SelectItem>();
		listDepartment.addAll(UtilDAO.getSelectItem("department"));
	}
	
	public void initBranch(){
		if(!Tool.isPostBack()){
			listBranch = new ArrayList<SelectItem>();
			listBranch.addAll(UtilDAO.getSelectItem("branch"));
		}
	}
	
	public void refreshBranch(){
		listBranch = new ArrayList<SelectItem>();
		listBranch.addAll(UtilDAO.getSelectItem("branch"));
	}
	
	public void initDesignation(){
		if(!Tool.isPostBack()){
			listDesignation = new ArrayList<SelectItem>();
			listDesignation.addAll(UtilDAO.getSelectItem("designation"));
		}
	}
	
	public void refreshDesignation(){
		listDesignation = new ArrayList<SelectItem>();
		listDesignation.addAll(UtilDAO.getSelectItem("designation"));
	}
	
	public ArrayList<SelectItem> getListDepartment() {
		return listDepartment;
	}
	public void setListDepartment(ArrayList<SelectItem> listDepartment) {
		this.listDepartment = listDepartment;
	}
	public ArrayList<SelectItem> getListDesignation() {
		return listDesignation;
	}
	public void setListDesignation(ArrayList<SelectItem> listDesignation) {
		this.listDesignation = listDesignation;
	}
	public ArrayList<SelectItem> getListBranch() {
		return listBranch;
	}
	public void setListBranch(ArrayList<SelectItem> listBranch) {
		this.listBranch = listBranch;
	}

	public void setListAttendanceType(ArrayList<SelectItem> listAttendanceType) {
		this.listAttendanceType = listAttendanceType;
	}

	public ArrayList<SelectItem> getListAttendanceType() {
		return listAttendanceType;
	}

	public void setListEmployee(ArrayList<hr_employee> listEmployee) {
		this.listEmployee = listEmployee;
	}

	public ArrayList<hr_employee> getListEmployee() {
		return listEmployee;
	}
	
}
